package cn.yh.springsecurity.utils;

import cn.yh.springsecurity.domain.entity.LoginUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

@Component
public class VerifyAuthorityUtils {

    public boolean hasAnyPerms(String perm){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication() ;

        LoginUser loginUser = (LoginUser) authentication.getPrincipal() ;

        return loginUser.getPermissions().contains(perm);
    }
}
